package test;

import grammar.Assembly;
import geometry.Box;
//import geometry.ComboBox;
import geometry.Geometry;
import grammar.Product;
import grammar.Design;
import grammar.InstantiationInput;
import grammar.ModificationRule;
import grammar.Rule;
import graph.GNode;

import java.util.HashMap;
import java.util.Map;

public class ShapeAnneal {

public static Design buildInitialConfiguration() {
    Design design = new Design();
    Product shape = design.setProduct("PRODUCT");
    Assembly assembly = design.addAssembly("ASSEMBLY");
    Box block = design.addBox(assembly,1,1,1,"PART");
    block.addLabel("HEAD");
    return design;
}
    
    public static Rule straight() {
        //LHS XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
        Design lhs = new Design();
        Product product = lhs.setProduct("PRODUCT");
        Assembly assembly = lhs.addAssembly("ASSEMBLY");
        Box block = lhs.addBox(assembly,1,1,1,"PART");
        block.addLabel("HEAD");

        //RHS XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
        Design rhs = new Design();
        rhs.setProduct(product);
        rhs.addGeometry(assembly,block);
        Box block2 = rhs.addBox(assembly,1,1,1,"PART");
        block2.translateBy(4, 0, 0);
        //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
        InstantiationInput input = new InstantiationInput();
        
        Rule rule = new ModificationRule(lhs, rhs, input, new GNode[]{});
        //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
        Map <Geometry, String[]> labelsToRemove = new HashMap<Geometry, String[]>();
        Map <Geometry, String[]> labelsToAdd = new HashMap<Geometry, String[]>();
        labelsToRemove.put(block, new String[]{"HEAD"});
        labelsToAdd.put(block2, new String[]{"HEAD"});
        rule.setLabelChanges(labelsToRemove, labelsToAdd);
        //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
        
        //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
        
        //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
        //Input variables
        return rule;    
    }

    public static Rule counterClockwise() {
        //LHS XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
        Design lhs = new Design();
        Product product = lhs.setProduct("PRODUCT");
        Assembly assembly = lhs.addAssembly("ASSEMBLY");
        Box block = lhs.addBox(assembly,1,1,1,"PART");
        block.addLabel("HEAD");

        //RHS XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
        Design rhs = new Design();
        rhs.setProduct(product);
        rhs.addGeometry(assembly,block);
        Box block2 = rhs.addBox(assembly,1,1,1,"PART");
        block2.translateBy(6, 0, 0);
        block2.rotate(6, 0, -90);
        //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
        InstantiationInput input = new InstantiationInput();
        
        Rule rule = new ModificationRule(lhs, rhs, input, new GNode[]{});
        //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
        Map <Geometry, String[]> labelsToRemove = new HashMap<Geometry, String[]>();
        Map <Geometry, String[]> labelsToAdd = new HashMap<Geometry, String[]>();
        labelsToRemove.put(block, new String[]{"HEAD"});
        labelsToAdd.put(block2, new String[]{"HEAD"});
        rule.setLabelChanges(labelsToRemove, labelsToAdd);
        //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
        
        //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
        
        //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
        //Input variables
        return rule;    
    }
    
    public static Rule clockwise() {
        //LHS XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
        Design lhs = new Design();
        Product product = lhs.setProduct("PRODUCT");
        Assembly assembly = lhs.addAssembly("ASSEMBLY");
        Box block = lhs.addBox(assembly,1,1,1,"PART");
        block.addLabel("HEAD");

        //RHS XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
        Design rhs = new Design();
        rhs.setProduct(product);
        rhs.addGeometry(assembly,block);
        Box block2 = rhs.addBox(assembly,1,1,1,"PART");
        block2.translateBy(4, 2, 0);
        block2.rotate(0, 0, 90);
        //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
        InstantiationInput input = new InstantiationInput();
        
        Rule rule = new ModificationRule(lhs, rhs, input, new GNode[]{});
        //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
        Map <Geometry, String[]> labelsToRemove = new HashMap<Geometry, String[]>();
        Map <Geometry, String[]> labelsToAdd = new HashMap<Geometry, String[]>();
        labelsToRemove.put(block, new String[]{"HEAD"});
        labelsToAdd.put(block2, new String[]{"HEAD"});
        rule.setLabelChanges(labelsToRemove, labelsToAdd);
        //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
        
        //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
        
        //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
        //Input variables
        return rule;    
    }
}
    